<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查询员工</title>
<link rel = "stylesheet" href = "css/bootstrap.min.css">
<link rel = "stylesheet" href = "css/bootstrap-theme.min.css">
<script type="text/javascript" src = "js/jquery.min.js"></script>
<script type="text/javascript" src = "js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="index.jsp" style="color:orange;font-weight:bold">企业管理系统</a>
    </div>

    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li><a href="login.jsp" style="color:blue;font-size:16px">欢迎${requestScope.manager.admin}进入<span class="sr-only">(current)</span></a></li>
      </ul>
      
      <ul class="nav navbar-nav navbar-right">
        <li><a href="login.jsp">退出登录</a></li>
      </ul>
    </div>
  </div>
</nav>

<div class="row">
	<div class="col-md-2" style="margin-left:30px">
		<%@include file="menu.jsp"%>
	</div>
	
	<div class="col-md-9">
		<div class="panel panel-default">
		  <div class="panel-heading">用户查询</div>
		  <div class="panel-body">
		    <c:if test="${requestScope.flag!=null }">
			  	<c:if test="${requestScope.flag==true }">
			  	  <div style="width:100%;text-align:center;">
			  		<span style="color:green;font-size:16px">删除成功</span>
			  	  </div>
			  	</c:if>
			  	<c:if test="${requestScope.flag==false }">
			  	  <div class="form-group">
			  	    <span style="color:green">删除失败</span>
			   	  </div>
			  	</c:if>
			  </c:if>
		    <div class="row">
		    	<div class="col-md-12">
		    		<table class="table table-striped">
					  <thead><tr><th>ID</th><th>姓名</th><th>年龄</th><th>所在部门</th><th>操作</th></tr></thead>
					  <tbody>
					  	<c:forEach items = "${requestScope.list }" var="item">
					  		<tr>
					  		<td>${item.id }</td>
					  		<td>${item.name }</td>
					  		<td><c:if test="${item.sex==1 }">男</c:if>
					  			<c:if test="${item.sex==0 }">女</c:if>
					  		</td>
					  		<td><c:if test="${item.did==1 }">研发部</c:if>
					  			<c:if test="${item.did==2 }">市场部</c:if>
					  			<c:if test="${item.did==3 }">售后部</c:if>
					  			<c:if test="${item.did==4 }">财务部</c:if>
					  			<c:if test="${item.did==5 }">管理部</c:if>
					  		</td>
					  		<td><a href="DeleteUserServlet?id=${item.id }&curpage=${requestScope.curpage }" style="color:white;background-color:blue;padding:3px">删除</a>
					  		    <a href="SelectUserServlet?id=${item.id }&name=${item.name }&age=${item.age }&sex=${item.sex }&did=${item.did }" style="color:white;background-color:green;padding:3px;margin-left:5px">更新</a>
					  		    </td>
					  		</tr>
					  	</c:forEach>
					  </tbody>
					</table>
		    	</div>
		    </div>
		    <div class="row">
		    <nav style="text-align:center">
			  <ul class="pagination">
			      <c:if test="${requestScope.curpage>1 }">
				      <li><a href="QueryPageServlet?curpage=${requestScope.curpage-1}" aria-label="Previous">
				        <span aria-hidden="true">&laquo;</span>
				      </a></li>
			      </c:if>
			    <c:forEach begin="1" step="1" end="${requestScope.counts }" var="item">
			      <c:if test="${requestScope.curpage==item }">
			        <li class="active"><a href="QueryPageServlet?curpage=${item }">${item}</a></li>
			      </c:if>
			      <c:if test="${requestScope.curpage!=item }">
			        <li><a href="QueryPageServlet?curpage=${item}">${item}</a></li>
			      </c:if>
			    </c:forEach>
			    <c:if test="${requestScope.curpage<requestScope.counts }">
				  <li><a href="QueryPageServlet?curpage=${requestScope.curpage+1}" aria-label="Next">
				    <span aria-hidden="true">&raquo;</span>
				  </a></li>
				 </c:if>
			  </ul>
			</nav>
		    </div>
		  </div>
		</div>
	</div>
</div>
</body>
</html>
